package WORKPLACE;

import java.net.InetAddress;
import java.net.UnknownHostException;

import javax.swing.JFrame;
import javax.swing.WindowConstants;

import TOOLS.SQLtool;
import TOOLS.messageTool;

public class myWorkPlaceUpdater {
	static messageTool mt=new messageTool();
	public static void main(String[] args) {
		SQLtool sql=new SQLtool();
		String IPaddr="192.168.1.1";
		try {
			InetAddress addr = InetAddress.getLocalHost();
			IPaddr=addr.getHostAddress();
		} catch (UnknownHostException e1) {
			;
		}
		sql.config(IPaddr, "AKS2019", "sa", "123456","myWorkPlaceUpdater");
		if(IPaddr.startsWith("192.168")) {
			sql.config("192.168.0.39", "AKS2019", "sa", "abcd1234!","myWorkPlaceUpdater");
		}else {
			sql.config("10.130.1.19","AKS2019", "sa", "abcd1234!","myWorkPlaceUpdater");
		}
		
//		sql.config("10.130.1.19","AKS2019", "sa", "abcd1234!");

		JFrame j=new JFrame();
		j.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		j.setVisible(true);
		j.setLocation(-800, 0);
		try {
			sql.setAppName("checkUpdate_AKS");
			sql.connect();
			c_autoUpdateTool cp=new c_autoUpdateTool(sql);
//			cp.checkUpdate();
//			cp.newVersion();
			cp.newVersionBySocket();
			System.exit(0);
		} catch (Exception e) {
			try {
				sql.setServer("192.168.0.39");
				sql.connect();
				c_autoUpdateTool cp=new c_autoUpdateTool(sql);
//				cp.checkUpdate();
//				cp.newVersion();
				cp.newVersionBySocket();
				System.exit(0);
			} catch (Exception e1) {
				try {
					sql.setServer("10.130.1.19");
					sql.connect();
					c_autoUpdateTool cp=new c_autoUpdateTool(sql);
//					cp.checkUpdate();
//					cp.newVersion();
					cp.newVersionBySocket();
					System.exit(0);
				} catch (Exception e2) {
					mt.show(e2.getMessage());
				}
			}
		}
	}
}

